﻿using FriendStar.Code;
using FriendStar.Domain.Entity.BaseData;
using FriendStar.Domain.IRepository.BaseData;
using FriendStar.Repository.BaseData;
using System.Collections.Generic;
using System.Linq;
using SqlSugarRepository;

namespace FriendStar.Application.BaseData
{
    public class BUS_SJ_DictionaryApp
    {
        private IBUS_SJ_DictionaryRepository service = new BUS_SJ_DictionaryRepository();
        public List<BUS_SJ_DictionaryEntity> GetList(string keyword)
        {
            var expression = ExtLinq.True<BUS_SJ_DictionaryEntity>();
            if (!string.IsNullOrEmpty(keyword))
            {
                expression = expression.And(t => t.FTypeNO.Contains(keyword));
            }
            return service.IQueryable(expression).OrderBy(t => t.UseUnit).ToList();
        }
        public List<BUS_SJ_DictionaryEntity> DictionaryStyle(string useUnit,string type)
        {
            var expression = ExtLinq.True<BUS_SJ_DictionaryEntity>();
            if (!string.IsNullOrEmpty(useUnit))
            {
                expression = expression.And(t => t.UseUnit==useUnit);
            }
            if (!string.IsNullOrEmpty(type))
            {
                expression = expression.And(t => t.FTypeNO==type);
            }
            return service.IQueryable(expression).Select(p=>new BUS_SJ_DictionaryEntity(){FTypeNO=p.FTypeNO,FTypeName=p.FTypeName}).OrderBy(t => t.UseUnit).ToList();
        } 
    }
}  